<template>
    <div class="layout">
        <div class="layout" ref="MapView"></div>
    </div>
</template>
<script>
import simpleMap from '@best/libs-cli/simpleMap/index.js'

var map = null;
var mapConfig = [{
    "type": "TD",
    "name": "天地图",
    "layerType": "background",
    "url": "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
    "default": false
}]
export default {
    data() {
        return {

        }
    },
    mounted() {
        map = simpleMap.initMap(this.$refs.MapView);
        map.addProviders(mapConfig);
        map.RightMenu.addMenuOptions([{
            name: '按钮1', event: (po) => {
                this.$Message.info({
                    background: true,
                    content: '按钮1 事件 <br> 经度：' + po.longitude + ' <br> 纬度' + po.latitude
                });
            }
        }, {
            name: '按钮2', event: (po) => {
                console.log(po);
                this.$Message.info({
                    background: true,
                    content: '按钮2 事件 <br>经度：' + po.longitude + ' <br> 纬度' + po.latitude
                });
            }
        }]);
    },
    methods: {
        changeSenceMode(type) {
            map.SenceMode = type;
            this.SenceMode = type;
        }
    },
    beforeDestroy() {
        // 页面被注销时，销毁地图
        map && map.destroy();
    }
}
</script>

<style scoped>
.layout {
    height: 100%;
    width: 100%;
}

.control {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 20px;
    color: #fff;
}
.title {
    color: #fff;
}
.Text {
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
}
</style>